<style>
.table th { border:1px solid #aaa;
			background: #e9e9e9;
			color: #666666;
			padding: 4px 8px;
			text-align: left;
			white-space: nowrap;
			height: 32px;
			line-height: 32px;}
.table td {
	border:1px solid #aaa;
	
}

</style>
 
<script>
$(document).ready(function(){	



$("#customer_source_123")
      .bind( 'focus', function(){ 
        
        $(this).autocomplete("search"); 

      }).bind( 'click', function(){ 

        $(this).autocomplete("search"); 
        
      } )
      .autocomplete({
        minLength: 0,
        source: function(request, response ) {
            //alert(request.term);
                    $.ajax({
                        url: "/customer_source/customer_source_josn",
                        dataType: "json",
                        data:{
                        query: request.term
                        },
                        success: function( data ) {

                            response( $.map( data, function( item ) {
                            return {
                                label: item.value,
                                value: item.value
                            }
                            }));
                        }
                    });
        },
        focus: function() {
          return false;
        },
        select: function( event, ui ) {
             var terms=new Array();
             if(this.value!="")
               terms = this.value.split("/ ");
             terms.pop();
             terms.push( ui.item.value );
             terms.push( "" );
             this.value = terms.join( "/ " );
             return false;
        }
      });

    

	
	$("#object_usage123123")
	  .bind( 'focus', function(){ 
		
	  	$(this).autocomplete("search"); 

	  }).bind( 'click', function(){ 

	  	$(this).autocomplete("search"); 
	  	
	  } )
	  .autocomplete({
		minLength: 0,
		source: function(request, response ) {
			//alert(request.term);
	                $.ajax({
	                    url: "/object_usage/object_usage_josn",
	                    dataType: "json",
	                    data:{
						query: request.term
	                    },
	                    success: function( data ) {

	                        response( $.map( data, function( item ) {
	                        return {
								label: item.value,
								value: item.value
	                        }
	                        }));
	                    }
	                });
	    },
		focus: function() {
		  return false;
		},
		select: function( event, ui ) {
			 var terms=new Array();
			 if(this.value!="")
			   terms = this.value.split("/ ");
			 terms.pop();
			 terms.push( ui.item.value );
			 terms.push( "" );
			 this.value = terms.join( "/ " );
			 return false;
		}
	  });	
});



function show_area(id) {
    $('#administrative_area_select').dialog({
        autoOpen: true,
        modal: true,
        width: 300,
        height: 550,
        buttons: {
            "確定": function() {
                if ($('#administrative_area_value').val() != "") {

                    var h_a = $("#hous_ebuilding_administrative_area").html();

                    $('#' + id).val(
                        
                        $('#administrative_country').find("option:selected").text() );

                    
                    //建物門牌  行政區 1
                    $.post("/address/administrative_area", {
                        id: $("#administrative_country :selected").val()
                    }, function(result) {
                        //alert("WTFFF");
                        if (result != "") {
                            $("#hous_ebuilding_street").html(result);
                            $("#house_building").val("");
                        }
                    });

                    ////////************************************************////////////////////

                    $.post("/circle/circle_josn", {
                        city: $('#administrative_city').find("option:selected").text(),
                        area: $('#administrative_country').find("option:selected").val()
                    }, function(result) {
                        if (result != "") {

                            $("#circle").html(result);

                        }

                    });

                   
                }
                $(this).dialog("close");
            },
            "取消": function() {
                $(this).dialog("close");
            }
        }
    });

}



</script> 
 <link href="/css/bootstrap/dist/css/bootstrap.css" type="text/css" rel="stylesheet">

        <form method="POST">

            
            <table class="table" style="width: 100%;margin: 0 auto;margin: 0px 0px 0px -52px;">
                <tbody><tr>
                        <th>客戶姓名</th>
                        <td>
                            <input type="text" info="姓名" class="check" id="name" name="name" value="<?=!empty($_POST["name"]) ?$_POST["name"]:""?>" >
                        </td>
                        <th>需求等級</th>
                        <td>
                            <select id="required_level"  name="required_level" class="full_select">
                                <option value="">&nbsp;</option>
                                <?
                                foreach($required_level as $key=>$val){
                                ?>
                                <option value="<?= $val->required_level_id ?>"
                                    <?=!empty($_POST["required_level"])?($_POST["required_level"]==$val->required_level_id ?' selected ':'' ):""; ?>
                                    >
                                    <?= $val->value ?></option>
                                <?
                                }
                                ?>
                            </select>
                        </td>
                        <th>需求類型</th>
                        <td>
                            <input type="checkbox"  value="1" id="type_sell" name="type_sell" >買賣
                            <input type="checkbox"  value="1" id="type_rent" name="type_rent" >租賃

                            <!--
                            <input type="checkbox" value="1" id="type_consignment" name="type_consignment">代銷
                            -->

                        </td>
                        <th>物件用途</th>
                        <td>
                        	<input type="text" name="object_usage" id="object_usage123123" class="full_select" value="<?=!empty($_POST["object_usage"]) ?$_POST["object_usage"]:""?>" >
                            
                        </td>
                    </tr>
                    <tr>
                        <th>建物面積</th>
                        <td colspan="3">
                            <input type="text" name="building_area1" id="building_area1"  value="<?=!empty($_POST["building_area1"]) ?$_POST["building_area1"]:""?>" > ~ 
                            <input type="text" name="building_area2" id="building_area2"  value="<?=!empty($_POST["building_area2"]) ?$_POST["building_area2"]:""?>" >坪
                        </td>
                        <th>室內面積</th>
                        <td colspan="3">
                            <input type="text" name="indoor_area1" id="indoor_area1"  value="<?=!empty($_POST["indoor_area1"]) ?$_POST["indoor_area1"]:""?>" > ~ 
                            <input type="text" name="indoor_area2" id="indoor_area2"  value="<?=!empty($_POST["indoor_area2"]) ?$_POST["indoor_area2"]:""?>" >坪
                        </td>
                    </tr>
                    <tr>
                        <th>土地面積</th>
                        <td colspan="3">
                            <input type="text" name="land_area1" id="land_area1" value="<?=!empty($_POST["land_area1"]) ?$_POST["land_area1"]:""?>" > ~ 
                            <input type="text" name="land_area2" id="land_area2" value="<?=!empty($_POST["land_area2"]) ?$_POST["land_area2"]:""?>" >坪
                        </td>
                        <th>總預算</th>
                        <td colspan="3">
                            <input type="text" class="post" name="total_budget1" id="total_budget1" value="<?=!empty($_POST["total_budget1"]) ?$_POST["total_budget1"]:""?>" > ~ 
                            <input type="text" class="post" name="total_budget2" id="total_budget2" value="<?=!empty($_POST["total_budget2"]) ?$_POST["total_budget2"]:""?>" >萬
                        </td>
                    </tr>
                    <tr>
                        <th>重點區域</th>
                        <td><input type="text"  name="key_areas" id="key_areas11" onclick="show_emphasis_area('key_areas11')" value="<?=!empty($_POST["key_areas"]) ?$_POST["key_areas"]:""?>" >
                        </td>
                        <th>指定大樓</th>
                        <td>
                            <input type="text"  name="specify_building" id="specify_building123" onclick="show_building_name('specify_building123')" value="<?=!empty($_POST["specify_building"]) ?$_POST["specify_building"]:""?>" >
                        </td>

                        <th>物件案名</th>
                        <td colspan="3">
                            <input type="text" name="object_name" id="object_name123" onclick="show_object_case_name('object_name123');" value="<?=!empty($_POST["object_name"]) ?$_POST["object_name"]:""?>" >
                        </td>
                    </tr>

                    <tr class="color">
                        <th>
                <div id="icon-plus">
                    <a onclick="query_more();" class="additem">
                        <i style="color:#25EA41" class="icon-plus" id="query_more_icon">&nbsp;&nbsp;
                        </i>
                    </a>&nbsp;
                    路段
                </div>
                </th>
                <td colspan="7">
                    <input type="text" style="width:260px;"  name="sections1" id="sections1234" onclick="show_address('sections1234');"  value="<?=!empty($_POST["sections1"]) ?$_POST["sections1"]:""?>" >
                    ~
                    <input type="text" style="width:260px;"  name="sections2" id="sections223" onclick="show_address('sections223');"  value="<?=!empty($_POST["sections2"]) ?$_POST["sections2"]:""?>" >
                </td>
                </tr>
                </tbody>
                <tbody style="display:;" id="query_more">
                    <tr class="color">
                        <th>行政區</th>
                        <td>
                            <input type="text" name="administrative_area" id="administrative_area_123" onclick="show_area('administrative_area_123');" value="<?=!empty($_POST["administrative_area"]) ?$_POST["administrative_area"]:""?>" >
                        </td>
                        <th>屋齡</th>
                        <td><input type="text"  name="year_of_construction1" id="year_of_construction1" style="width:36px;"  value="<?=!empty($_POST["year_of_construction1"]) ?$_POST["year_of_construction1"]:""?>" >~
                        	<input type="text"  name="year_of_construction2" id="year_of_construction2" style="width:36px;"  value="<?=!empty($_POST["year_of_construction2"]) ?$_POST["year_of_construction2"]:""?>" >年</td>
                        <th>物件案別</th>
                        <td>
                        	<?php
                        	
                        	$_a=false;
							$_b=false;
							$_c=false;
							
                        	if(!empty($_POST["object_case_type"]) ){
                        		$oct=$_POST["object_case_type"];
								
								foreach($oct as $_a =>$_v){
								
									if($_v==1)
										$_a=true;
									
									if($_v==2)
										$_b=true;
									
									if($_v==3)
										$_c=true;
									
								}
								
							}
							
							
                        	
                        	?>
                            <input type="checkbox" value="1" name="object_case_type[]" class="post"  <?=($_a==true)?"checked":""?> >中古屋
                            <input type="checkbox" value="2" name="object_case_type[]" <?=($_b==true) ?"checked":""?> >預售
                            <input type="checkbox" value="3" name="object_case_type[]" <?=($_c==true) ?"checked":""?> >標售
                        </td>
                        <th>狀態</th>
                        <td>
                            <select name="status" id="status" class="full_select">
                                <option value="">&nbsp;</option>
                                
                                <option value="Y" <?=!empty($_POST["status"]) ?($_POST["status"]=="Y" ?" SELECTED " :''):""?> >有效</option>
                                <option value="N" <?=!empty($_POST["status"]) ?($_POST["status"]=="N" ?" SELECTED " :''):""?> >無效</option>
                                
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th>客戶來源</th>
                        <td>
                            <input type="text" name="customer_source" id="customer_source_123" class="full_select">
                               
                        </td>
                        <th>建檔日期</th>
                        <td>
                            <input type="text" class="Wdate" style="width:92px;" onclick="WdatePicker()" name="sctime" id="sctime"  value="<?=!empty($_POST["sctime"]) ?$_POST["sctime"]:""?>" >~
                            <input type="text" class="Wdate" style="width:92px;" onclick="WdatePicker()" name="ectime" id="ectime" value="<?=!empty($_POST["ectime"]) ?$_POST["ectime"]:""?>" >
                        </td>
                        <th>關鍵字</th>
                        <td><input type="text" name="keywords" id="keywords"  value="<?=!empty($_POST["keywords"]) ?$_POST["keywords"]:""?>" ></td>
                        <th>經紀人</th>
                        <td>
                            <select type="text" name="broker" id="broker">
                                <option></option>
                            <?php
                            foreach($all_users as $user ){
                            	
                                echo '<option value="'.$user->users_id .'" ';
								
								if(!empty($_POST["broker"]))
								if($user->users_id==$_POST["broker"]){
									
									echo " SELECTED ";
								}
								
                                echo ' >';
                                echo $user->name;
                                echo '</option>';
								
                            }
                            ?>
                            </selctl>

                        </td>
                    </tr>
                </tbody>
                <tfoot>
                    <tr>
                        <td>&nbsp;</td>
                        <td colspan="7">
                            <input type="submit" value="查詢確認" class="input_background">

                        </td>
                    </tr>
                </tfoot></table></form>
